package com.probiz.estore.common.model.system;

import java.util.Comparator;

import org.apache.commons.lang.StringUtils;

public class RegionVO implements Comparable{
	private Integer regionId;
	private String regionName;
	private Integer parentRegionId;
	private Integer regionType;
	private String telephoneCode;
	private Integer version;
	private String regionCode;
	private String zipCode;
	private Integer status;
	private int enabledDel;
	
	public RegionVO(Region region) {
		super();
		this.setRegionId(region.getRegionId());
		this.setRegionName(region.getRegionName());
		this.setParentRegionId(region.getParentId());
		this.setRegionType(region.getRegionType());
		this.setTelephoneCode(region.getTelephoneCode());
		this.setVersion(region.getVersion());
		this.setRegionName(region.getRegionName());
		this.setRegionCode(region.getRegionCode());
		this.setZipCode(region.getZipCode());
	}
	
	public int getEnabledDel() {
		return enabledDel;
	}
	public void setEnabledDel(int enabledDel) {
		this.enabledDel = enabledDel;
	}
	public String getZipCode() {
		return zipCode;
	}
	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}
	public String getRegionCode() {
		return regionCode;
	}
	public void setRegionCode(String regionCode) {
		this.regionCode = regionCode;
	}
	public Integer getVersion() {
		return version;
	}
	public void setVersion(Integer version) {
		this.version = version;
	}
	public String getTelephoneCode(){
		return telephoneCode;
	}
	public void setTelephoneCode(String telephoneCode) {
		this.telephoneCode = telephoneCode;
	}
	/**
	 * @return 
	 */
	public Integer getRegionType() {
		return regionType;
	}
	/**
	 * @param regionType 
	 */
	public void setRegionType(Integer regionType) {
		this.regionType = regionType;
	}
	public Integer getParentRegionId() {
		return parentRegionId;
	}
	public void setParentRegionId(Integer parentRegionId) {
		this.parentRegionId = parentRegionId;
	}
	public Integer getRegionId() {
		return regionId;
	}
	public void setRegionId(Integer regionId) {
		this.regionId = regionId;
	}
	public String getRegionName() {
		return regionName;
	}
	public void setRegionName(String regionName) {
		this.regionName = regionName;
	}
	public String toString(){
		StringBuffer result=new StringBuffer();
		result.append("regionId:"+this.regionId);
		result.append("regionName:"+this.regionName);
		result.append("parentRegionId:"+this.parentRegionId);
		result.append("regionType:"+this.regionType);
		
		return result.toString();
	}
	public int compareTo(Object arg0) {
		RegionVO that = (RegionVO)arg0;
		String thatName = that.getRegionName();
		Comparator cmp = java.text.Collator.getInstance();
		return cmp.compare(this.regionName, thatName);
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((parentRegionId == null) ? 0 : parentRegionId.hashCode());
		result = prime * result
				+ ((regionCode == null) ? 0 : regionCode.hashCode());
		result = prime * result
				+ ((regionId == null) ? 0 : regionId.hashCode());
		result = prime * result
				+ ((regionName == null) ? 0 : regionName.hashCode());
		result = prime * result
				+ ((regionType == null) ? 0 : regionType.hashCode());
		result = prime * result + ((status == null) ? 0 : status.hashCode());
		result = prime * result
				+ ((telephoneCode == null) ? 0 : telephoneCode.hashCode());
		result = prime * result + ((version == null) ? 0 : version.hashCode());
		result = prime * result + ((zipCode == null) ? 0 : zipCode.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final RegionVO other = (RegionVO) obj;
		if (parentRegionId == null) {
			if (other.parentRegionId != null)
				return false;
		} else if (!parentRegionId.equals(other.parentRegionId))
			return false;
		if (regionCode == null) {
			if (other.regionCode != null)
				return false;
		} else if (!regionCode.equals(other.regionCode))
			return false;
		if (regionId == null) {
			if (other.regionId != null)
				return false;
		} else if (!regionId.equals(other.regionId))
			return false;
		if (regionName == null) {
			if (other.regionName != null)
				return false;
		} else if (!regionName.equals(other.regionName))
			return false;
		if (regionType == null) {
			if (other.regionType != null)
				return false;
		} else if (!regionType.equals(other.regionType))
			return false;
		if (status == null) {
			if (other.status != null)
				return false;
		} else if (!status.equals(other.status))
			return false;
		if (telephoneCode == null) {
			if (other.telephoneCode != null)
				return false;
		} else if (!telephoneCode.equals(other.telephoneCode))
			return false;
		if (version == null) {
			if (other.version != null)
				return false;
		} else if (!version.equals(other.version))
			return false;
		if (zipCode == null) {
			if (other.zipCode != null)
				return false;
		} else if (!zipCode.equals(other.zipCode))
			return false;
		return true;
	}
	
	
	
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
		
}
